home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2000 September / september_2000.iso / intercd / root / ^Linux / cfengine-1.5.3 / src / read.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-07-13  |  2.4 KB  |  72 lines

  1. /* cfengine for GNU
  2.  
  3.         Copyright (C) 1995
  4.         Free Software Foundation, Inc.
  5.  
  6.    This file is part of GNU cfengine - written and maintained 
  7.    by Mark Burgess, Dept of Computing and Engineering, Oslo College,
  8.    Dept. of Theoretical physics, University of Oslo
  9.  
  10.    This program is free software; you can redistribute it and/or modify it
  11.    under the terms of the GNU General Public License as published by the
  12.    Free Software Foundation; either version 2, or (at your option) any
  13.    later version.
  14.  
  15.    This program is distributed in the hope that it will be useful,
  16.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.    GNU General Public License for more details.
  19.  
  20.   You should have received a copy of the GNU General Public License
  21.   along with this program; if not, write to the Free Software
  22.   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
  23.  
  24. */
  25.  
  26. /*===========================================================================*/
  27. /*                                                                           */
  28. /* File: read.c                                                              */
  29. /*                                                                           */
  30. /* Created: Mon Sep 29 09:22:33 1997                                         */
  31. /*                                                                           */
  32. /* Revision: $Id$                                                            */
  33. /*                                                                           */
  34. /* Description:                                                              */
  35. /*                                                                           */
  36. /*===========================================================================*/
  37.  
  38. #include "cf.defs.h"
  39. #include "cf.extern.h"
  40.  
  41. /*********************************************************************/
  42.  
  43. ReadLine(buff,size,fp)
  44.  
  45. char *buff;
  46. int size;
  47. FILE *fp;
  48.  
  49. {
  50. buff[0] = '\0';
  51. buff[size - 1] = '\0';                        /* mark end of buffer */
  52.  
  53. if (fgets(buff, size, fp) == NULL)
  54.    {
  55.    *buff = '\0';                   /* EOF */
  56.    return false;
  57.    }
  58. else
  59.    {
  60.    char *tmp;
  61.  
  62.    /* remove newline */
  63.  
  64.    if ((tmp = strrchr(buff, '\n')) != NULL)
  65.       {
  66.       *tmp = '\0';
  67.       }
  68.    }
  69.  
  70. return true; 
  71. }
  72.